#include "WorkDataProxy.hpp"

WorkDataProxy::WorkDataProxy()
{
  sessionConn=sdbus::createSessionBusConnection();
  proxy=sdbus::createProxy(*sessionConn,"org.HBTY.WorkDataManager","/org/HBTY/WorkDataManager");
}

WorkDataProxy::~WorkDataProxy()
{

}

long WorkDataProxy::CreateTask(std::string name)
{
  long returnVal;
  proxy->callMethod("CreateTask").onInterface(InterFaceName).withArguments(name).storeResultsTo(returnVal);
  return returnVal;
}

void WorkDataProxy::DeleteTask(long task_id)
{
  proxy->callMethod("DeleteTask").onInterface(InterFaceName).withArguments(task_id);
}

std::vector<std::string> WorkDataProxy::GetTaskNameList()
{
  std::vector<std::string> ret;
  proxy->callMethod("GetTaskNameList").onInterface(InterFaceName).storeResultsTo(ret);
  return ret;
}

std::vector<long> WorkDataProxy::GetTaskIDList()
{
  std::vector<long> ret;
  proxy->callMethod("GetTaskIDList").onInterface(InterFaceName).storeResultsTo(ret);
  return ret;
}

std::vector<long> WorkDataProxy::GetRecordID(long task_id)
{
  std::vector<long> ret;
  proxy->callMethod("GetRecordID").onInterface(InterFaceName).withArguments(task_id).storeResultsTo(ret);
  return ret;
}

std::tuple<long,long,std::string,bool,bool> WorkDataProxy::GetRecordInf(long rec_id)
{
  std::tuple<long,long,std::string,bool,bool> ret;
  proxy->callMethod("GetRecordInf").onInterface(InterFaceName).withArguments(rec_id).storeResultsTo(ret);
  return ret;
}

long WorkDataProxy::CreateRecord(long stu_id,long task_id)
{
  long ret;
  proxy->callMethod("CreateRecord").onInterface(InterFaceName).withArguments(stu_id,task_id).storeResultsTo(ret);
  return ret;
}

void WorkDataProxy::LoadTaskInf()
{
  proxy->callMethod("LoadTaskInf").onInterface(InterFaceName);
}

void WorkDataProxy::FinishRecord(long rec_id)
{
  proxy->callMethod("FinishRecord").onInterface(InterFaceName).withArguments(rec_id);
}

std::string WorkDataProxy::GetRecordPath(long rec_id)
{
  std::string val;
  proxy->callMethod("GetRecordPath").onInterface(InterFaceName).withArguments(rec_id).storeResultsTo(val);
  return val;
}

std::string WorkDataProxy::GetStudentInfo(long stu_id)
{
  std::string val;
  proxy->callMethod("GetStudentInfo").onInterface(InterFaceName).withArguments(stu_id).storeResultsTo(val);
  return val;
}

std::vector<long> WorkDataProxy::GetRecordHandleFinishList()
{
  std::vector<long> val;
  proxy->callMethod("GetRecordFinishHandleList").onInterface(InterFaceName).storeResultsTo(val);
  return val;
}

std::tuple<std::string,std::string> WorkDataProxy::GetTaskInf(long task_id)
{
  std::tuple<std::string,std::string> res;
  proxy->callMethod("GetTaskInf").onInterface(InterFaceName).withArguments(task_id).storeResultsTo(res);
  return res;
}

std::vector<long> WorkDataProxy::GetRecordHandleFinishListWithTask(long taskid)
{
  std::vector<long> res;
  proxy->callMethod("GetRecordFinishHandleListWithTask").onInterface(InterFaceName).withArguments(taskid).storeResultsTo(res);
  return res;
}

bool WorkDataProxy::OutputData(long rec_id,std::string path)
{
  bool ret;
  proxy->callMethod("OutputData").onInterface(InterFaceName).withArguments(rec_id,path).storeResultsTo(ret);
  return ret;
}
